<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Invoice extends MY_Controller
{
    /**
     * Index Page for this controller.
     */
    public function index()
    {

        $this->load->library('C_invoice_list');

        $sendData = array();
        $sendData['enterpriseId'] = $this->lg_user['enterpriseId'];
        $sendData['channelId'] = $this->lg_user['channelId'];
        $sendData['userType'] = $this->lg_user['type'];
        $sendData['uid'] = $this->lg_user['id'];
        $sendData['password'] = $this->lg_user['password'];

        //制造接口请求
        $url = $this->c_invoice_list->set_call_items($sendData);
        $param = $this->c_invoice_list->get_call_items();
        $rs = $this->restcurl->get($url, $param);
        if ($rs && $rs['ErrorCode'] == 0 && $rs['Success'] == 1) {
            $this->data['invoiceDate'] = $rs['CallInfo'];;
        }
        $this->render('invoice/index', $this->data);
    }
    public function add(){
        $this->render('invoice/add', $this->data);
    }
    public function detail(){
        $this->load->library('C_invoice_detail');

        $sendData = array();
        $sendData['enterpriseId'] = $this->lg_user['enterpriseId'];
        $sendData['channelId'] = $this->lg_user['channelId'];
        $sendData['userType'] = $this->lg_user['type'];
        $sendData['uid'] = $this->lg_user['id'];
        $sendData['password'] = $this->lg_user['password'];
        $sendData['invoice_id'] = $this->input->get('invoice_id');
        $this ->c_invoice_detail->set_resource_id($sendData['invoice_id']);
        //制造接口请求
        $url = $this->c_invoice_detail->set_call_items($sendData);
        $param = $this->c_invoice_detail->get_call_items();
        $rs = $this->restcurl->get($url, $param);
        if ($rs && $rs['ErrorCode'] == 0 && $rs['Success'] == 1) {
            $info = array_merge($rs['CallInfo'],$sendData);
            $this->data['invoiceDate'] = $info;;
        }
        $this->render('invoice/detail', $this->data);
    }
}
